import java.util.Vector;

/**
 * basic data structure for the index of a method
 * 
 * @author Steven Hsui
 * 
 */
public class IndexMethod {
	/**
	 * all the paths in the method
	 */
	private Vector<IndexPath> paths;
	
	/**
	 * the name of the method
	 */
	private String name;

	public IndexMethod() {
		this.paths = new Vector<IndexPath>();
	}

	public void addPath(IndexPath path) {
		this.paths.add(path);
	}

	public IndexPath getPath(int index) {
		return this.paths.get(index);
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.name + " size:" + this.paths.size() + "\n");
		for (int i = 0; i < this.paths.size(); i++) {
			sb.append("path" + i + "\n");
			sb.append(paths.get(i).toString() + "\n");
		}
		return sb.toString();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int size() {
		return paths.size();
	}

	public Vector<String> getPathVector() {
		Vector<String> vpaths = new Vector<String>();
		for (int i = 0; i < paths.size(); i++) {
			IndexPath path = paths.get(i);
			vpaths.add(paths.get(i).toString());
		}
		return vpaths;
	}
}
